<%layout("/common/_layout.html"){ %>
<script type="text/javascript">
	var keywordsObj = {};
	var submit_btn = function(){
		if($("#api").val())
			keywordsObj.api = $("#api").val();
		if($("#describes").val())
			keywordsObj.describes = $("#describes").val();
		var keywords = "";
		if(!$.isEmptyObject(keywordsObj)){
			keywords = JSON.stringify(keywordsObj);
		}
		$("#keywords").val(keywords);
		$("#list-form").submit();
	}
	var deleteDescribe = function(url){
		var $idsCheckedCheck = $("[name='ids']:checked");
		var $deleteButton = $("#deleteButton");// 删除按钮
		var ids = $idsCheckedCheck.serialize();
		if(window.confirm('你确定要删除选中数据吗？')){
			$.ajax({
				url : url,
				data : ids,
				dataType : "json",
				async : false,
				beforeSend : function(data) {
					$deleteButton.prop("disabled", true)
				},
				success : function(data) {
					$deleteButton.prop("disabled", false)
					if(data.message=="success"){
						alert("删除成功");
						window.location.href="${base}/transactionLog/apiDescribeOperateList?pageNumber=1&pageSize=10";
					}else if(data.message=="failed"){
						alert("删除失败");
					}
				}

			});
		}
	}




	/*var updateDescribe = function(id){
		$.ajax({
			url : "/promotion/update",
			data : {"id":id},
			dataType : "json",
			async : false,
			success : function(data) {
				if(data.message=="success"){
					alert("删除成功");
					window.location.href="${base}/promotion/list?pageNumber=1&pageSize=10";
				}else if(data.message=="failed"){
					alert("删除失败");
				}
			}

		});
	}*/
</script>

<%#ajax userTable:{%>
<div class="am-cf am-padding">
	<div class="am-fl am-cf">
		<strong class="am-text-primary am-text-lg">后台管理</strong> / <small>接口描述管理</small>
	</div>
</div>

<div class="am-g">
	<%include("transaction_api_describe_query.tpl"){}%>
	<div class="am-u-sm-12 am-u-md-12"
		 style="padding: 0 1.6rem 1.6rem 1rem; margin: 0;">
		<div class="am-btn-toolbar" style="padding-left: .5rem;">
			<div class="am-btn-group am-btn-group-xs">
				<div class="am-btn-group am-btn-group-xs am-form-file">
					<%if(so.hasPermission("API_DESCRIBE_ADD")) {%>
					<button type="button" id="bt_add" class="am-btn"
							onclick="location.href='${base}/transactionLog/apiDescribeAdd'">
						<span class="am-icon-plus"> 新增</span>
					</button>
					<%}%>
					<%if(so.hasPermission("API_DESCRIBE_DELETE")) {%>
					<button type="button" id="deleteButton" disabled="disabled" class="am-btn am-btn-default" onclick="deleteDescribe('${base}/transactionLog/deleteApiDescribe')"><span class="am-icon-trash-o"></span> 删除</button>
					<%}%>
				</div>
			</div>
		</div>
	</div>
</div>

<div class="am-g">
	<div class="am-u-sm-12">
		<div class="am-scrollable-horizontal">
			<table class="am-table am-table-striped am-table-hover table-main" style="TABLE-LAYOUT: fixed">
				<thead>
				<tr class="am-text-nowrap">
					<th class="table-check"><input type="checkbox" id="allCheck"></th>
					<th class="table-title" >id</th>
					<th class="table-title" >api</th>
					<th class="table-title" >描述</th>
					<th class="table-title" >操作</th>
				</tr>
				</thead>
				<tbody>
				<%for(item in pager.list!){%>
				<tr>
					<td><input type="checkbox" <%{%>name="ids" value="${item.id}"<%}%> /></td>
					<td style="word-wrap:break-word;">${item.id}</td>
					<td style="word-wrap:break-word;">${item.api}</td>
					<td style="word-wrap:break-word;">${item.describes}</td>
					<td>
						<div class="am-btn-toolbar">
							<div class="am-btn-group am-btn-group-xs">
								<%if(so.hasPermission("API_DESCRIBE_EDIT")) {%>
								<div style="float: left">
									<button type="button"
											class="am-btn am-btn-default am-btn-xs am-text-secondary"
											onclick="location.href='${base}/transactionLog/apiDescribeEdit?id=${item.id}'">
										<span class="am-icon-pencil-square-o"></span>编辑
									</button>&nbsp;&nbsp;
								</div>
								<%}%>
							</div>
						</div>
					</td>

				</tr>
				<%}%>
				</tbody>
			</table>
		</div>

		<div class="am-cf">
			<!-- 分页 -->
			<%if (pager.list.~size > 0){%>
			<div class="am-fr"><% include("/admin/common_pager.tpl"){}%></div>
			<%}else{%>
			<div class="am-kai">
				<h3>没有找到任何记录!</h3>
			</div>
			<%}%>
		</div>

	</div>
</div>
<div class="am-modal am-modal-no-btn" tabindex="-1" id="modal">
	<div class="am-modal-dialog">
		<div class="am-modal-hd">
			<i class="am-icon-refresh am-icon-spin"></i> <a
				href="javascript: void(0)" class="am-close am-close-spin"
				data-am-modal-close>&times;</a>
		</div>
		<div class="am-modal-bd">正在处理，请稍等...</div>
	</div>
</div>
<%}%> <%}%>